package com.coin;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * Created by chenhao on 2017/3/28.
 */
@Configuration
public class DataSourceManager {

    @Bean(name = "accountDataSource")
    @Qualifier("accountDataSource")
    @Primary
    @ConfigurationProperties(prefix="spring.datasource.account")
    public DataSource accountingMasterDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "flowDataSource")
    @Qualifier("flowDataSource")
    @ConfigurationProperties(prefix="spring.datasource.flow")
    public DataSource accountingSlaveDataSource() {
        return DataSourceBuilder.create().build();
    }
}
